import request from '@/utils/request'

/**
 * @api {post} /agents 获取经纪
 * @apiName getAgents
 * @apiGroup 经纪
 * @apiVersion 1.0.0
 *
 * @apiQuery {String} _limit 获取数据的条数, -1 为所有数据
 * @apiQuery {String} _start 指定全部第几条开始获取, 用作翻页
 *
 * @apiSuccess {Array} - 经纪列表
 */

export function getAgents(params) {
  return request({
    url: '/agents',
    params
  })
}

export function getAgentsCount(params) {
  return request({
    url: '/agents/count',
    params
  })
}

export function delAgent(id) {
  return request({
    url: `/agents/${id}`,
    method: 'delete'
  })
}

export function addAgent(data) {
  return request({
    url: '/agents',
    method: 'post',
    data
  })
}

export function getAgentDetail(id) {
  return request({
    url: `/agents/${id}`
  })
}

export function updateAgent(data) {
  return request({
    url: `/agents/${data.id}`,
    method: 'put',
    data
  })
}
